package org.easymodelers.gmf.creator.template;

import org.easymodelers.gmf.utils.ModelsManager;
import org.easymodelers.template.NamespaceData;
import org.easymodelers.template.TemplateHandler;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.gmf.gmfgraph.Canvas;
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
import org.eclipse.gmf.mappings.GMFMapFactory;
import org.eclipse.gmf.tooldef.GMFToolFactory;
import org.eclipse.gmf.tooldef.ToolRegistry;

public abstract class AbstractMapTemplateBasedElementDefinitionHandler extends AbstractTemplateBasedElementDefinitionHandler {

	protected void initializeTemplateHandler(TemplateHandler templateHandler, ModelsManager modelsManager) {
		Canvas canvas = modelsManager.getCanvas();
		ToolRegistry toolRegistry = modelsManager.getToolRegistry();
		EPackage metamodel = modelsManager.getMetaModel();

		templateHandler.registerDefaultNamespaces();
		templateHandler.registerNamespace(
				new NamespaceData("gmfgraph", "http://www.eclipse.org/gmf/2006/GraphicalDefinition",
									GMFGraphFactory.eINSTANCE, canvas));
		templateHandler.registerNamespace(
				new NamespaceData("gmftool", "http://www.eclipse.org/gmf/2005/ToolDefinition",
									GMFToolFactory.eINSTANCE, toolRegistry));
		templateHandler.registerNamespace(
				new NamespaceData("gmfmap", "http://www.eclipse.org/gmf/2008/mappings",
									GMFMapFactory.eINSTANCE, null));
		templateHandler.registerNamespace(
				new NamespaceData("ecore", "http://www.eclipse.org/emf/2002/Ecore",
									EcoreFactory.eINSTANCE, metamodel, true));
	}
}
